delphifandomcom-20200223-history
Adding TortoiseSVN to the Tools menu
The Tools Menu of the Delphi IDE allows you to add additional items. In this article you will learn how to add entries for calling some TortoiseSVN commands. Basics TortoiseSVN comes with a tool TortoiseProc which allows you to call the various commands using the commandline. There is one particular oddity to be aware of: If you get an "Access to was denied" you forgot to specify the /notempfile option. The Delphi IDE allows adding custom entries to the Tools menu that can contain macros that will be resolved when the entry is selected. Preparations The Delphi IDE has got a bug resolving macros if these are not preceded by a space, e.g. /path:$path($project)) will not be resolved. This is quite annoying but we can work around it by using a batch file like this: @ECHO OFF rem This is a workaround for the Delhi IDE's bug rem to not resolve macros if they are part of rem a "word" e.g.: rem /path:$path($project)) rem is not resolved start "TortoiseSVN" "c:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /notempfile /command:%1 /path:%2 Put this batch file whereever you like it, e.g. to c:\bin\svn-cmd.cmd. You will need to specify the full path to it when you add entries to the tools menu. The batch requires two parameters: * The command to execute, e.g. commit, update * The directory on which to execute the command Adding a Commit entry The first item we will add is a SVN Commit Project entry: # Select Tools / Configure Tools ... to open the Tool Options Dialog # Press Add to open the Tool Properties dialog # Enter "SVN Commit Project" as the Title # Enter "c:\bin\svn-cmd.cmd" as Program # Leave Working dir empty # Enter "commit $PATH($PROJECT) $SAVEALL" as Parameters # Press OK and Close to leave the dialogs Now there is an entry SVN Commit Project in the tools menu. When you select it, it will call the commit dialog of TortoiseSVN as if you right clicked on the directory and selected commit from the context menu. Of course this works only if the directory contains source code that was previously checked out of a Subversion repository. Adding an Update entry Now we will add an SVN Update Project entry. Basically this just replaces the commit command with the update command: # Select Tools / Configure Tools ... to open the Tool Options Dialog # Press Add to open the Tool Properties dialog # Enter "SVN Update Project" as the Title # Enter "c:\bin\svn-cmd.cmd" as Program # Leave Working dir empty # Enter "update $PATH($PROJECT) $SAVEALL" as Parameters # Press OK and Close to leave the dialogs Adding a Check entry The last entry we want to add is "SVN Check Project" which will check for modified files. Again, this just replaces the command with repostatus: # Select Tools / Configure Tools ... to open the Tool Options Dialog # Press Add to open the Tool Properties dialog # Enter "SVN Project" as the Title # Enter "c:\bin\svn-cmd.cmd" as Program # Leave Working dir empty # Enter "repostatus $PATH($PROJECT) $SAVEALL" as Parameters # Press OK and Close to leave the dialogs Adding a Browse entry Ok, I lied, we will add another entry: "SVN Browse Project" which opens the repository browser for the current project. We don't really need the $SAVEALL macro here but just in case we add it anyway. # Select Tools / Configure Tools ... to open the Tool Options Dialog # Press Add to open the Tool Properties dialog # Enter "SVN Project" as the Title # Enter "c:\bin\svn-cmd.cmd" as Program # Leave Working dir empty # Enter "repobrowser $PATH($PROJECT) $SAVEALL" as Parameters # Press OK and Close to leave the dialogs Diff the topmost editor file To view a diff of the current topmost editor file, add a new tools entry with the following settings: # Set title to: "SVN Diff" # Set program to: "c:\bin\svn-cmd.cmd" # Set Parameters to: "diff $EDNAME $SAVE" Log of the topmost editor file To show the log of the current topmost editor file, add a new tools entry with the following settings: # Set title to: "SVN Log" # Set program to: "c:\bin\svn-cmd.cmd" # Set Parameters to: "log $EDNAME $SAVE" External Links *TortoiseSVN Homepage *Tigris Homepage Category:Delphi IDE Category:Tips and Tricks